package com.iven.xie.controller;

import com.iven.xie.beans.ResObject;
import com.iven.xie.entity.DbConfig;
import com.iven.xie.service.ConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author iven.xie
 */
@Api(tags = "数据库配置相干接口")
@RestController
@RequiredArgsConstructor
@RequestMapping("api/db/config")
@Slf4j
public class ConfigController {
    @Autowired
    private ConfigService configService;

    @ApiOperation(value = "获取默认配置文件配置", notes = "获取默认配置文件配置")
    @GetMapping("/default")
    public ResObject<Map<String, DbConfig>> getDeFaultConfig() {
        ResObject resObject = new ResObject();
        resObject.setCode(HttpStatus.OK.value());
        resObject.setData(configService.getDeFaultConfig());
        return resObject;
    }

}
